}
rec->name = xstrdup( wpt->description );
- if ( !nogc && wpt->gc_data.id ) {
- char *extra = xmalloc( 25 + strlen(wpt->gc_data.placer) + strlen( wpt->shortname ));
+ if ( !nogc && wpt->gc_data->id ) {
+ char *extra = xmalloc( 25 + strlen(wpt->gc_data->placer) + strlen( wpt->shortname ));
sprintf( extra, "\r\nBy %s\r\n%s (%1.1f/%1.1f)",
- wpt->gc_data.placer,
- wpt->shortname, wpt->gc_data.diff/10.0,
- wpt->gc_data.terr/10.0);
+ wpt->gc_data->placer,
+ wpt->shortname, wpt->gc_data->diff/10.0,
+ wpt->gc_data->terr/10.0);
rec->name = xstrappend( rec->name, extra );
xfree( extra );
}
waypoint *w = (waypoint *)wpt;
format_specific_data *fs;
url_link *url_next;
+ geocache_data *gc_data = (geocache_data *)wpt->gc_data;
if ((cet_output == 0) && (w->wpt_flags.cet_converted != 0)) return;
url_next->url = cet_convert_string(url_next->url);
url_next->url_link_text = cet_convert_string(url_next->url_link_text);
}
+ gc_data->placer = cet_convert_string(gc_data->placer);
+ gc_data->hint = cet_convert_string(gc_data->hint);
fs = wpt->fs;
while (fs != NULL)
}
vdata += strlen( vdata ) + 1;
- if (wpt->gc_data.diff) {
+ if (wpt->gc_data->diff) {
xasprintf(&desc_geo, "%s%s by %s\n%.4s/%.4s %3.1f/%3.1f\n",
- wpt->gc_data.is_available==status_true ?
+ wpt->gc_data->is_available==status_true ?
"" : " (Disabled)",
- wpt->gc_data.is_archived==status_true ?
+ wpt->gc_data->is_archived==status_true ?
" (Archived)" : "",
- wpt->gc_data.placer,
- gs_get_cachetype(wpt->gc_data.type),
- gs_get_container(wpt->gc_data.container),
- wpt->gc_data.diff/10.0,
- wpt->gc_data.terr/10.0);
+ wpt->gc_data->placer,
+ gs_get_cachetype(wpt->gc_data->type),
+ gs_get_container(wpt->gc_data->container),
+ wpt->gc_data->diff/10.0,
+ wpt->gc_data->terr/10.0);
} else {
desc_geo = xstrdup("");
}
- if (wpt->gc_data.desc_short.utfstring) {
- char *stripped_html = strip_html(&wpt->gc_data.desc_short);
- desc_short = xstrdup(wpt->gc_data.diff == 0 ? "\n\n" : "");
+ if (wpt->gc_data->desc_short.utfstring) {
+ char *stripped_html = strip_html(&wpt->gc_data->desc_short);
+ desc_short = xstrdup(wpt->gc_data->diff == 0 ? "\n\n" : "");
desc_short = xstrappend(desc_short, xstrdup(stripped_html));
xfree(stripped_html);
} else {
desc_short = xstrdup("");
}
- if (wpt->gc_data.desc_long.utfstring) {
- char *stripped_html = strip_html(&wpt->gc_data.desc_long);
+ if (wpt->gc_data->desc_long.utfstring) {
+ char *stripped_html = strip_html(&wpt->gc_data->desc_long);
desc_long = xstrdup("\n\n");
desc_long = xstrappend(desc_long, xstrdup(stripped_html));
xfree(stripped_html);
}
vdata += strlen( vdata ) + 1;
- if (wpt->gc_data.hint) {
- char *hint = xstrdup(wpt->gc_data.hint);
+ if (wpt->gc_data->hint) {
+ char *hint = xstrdup(wpt->gc_data->hint);
rec->type = WptCache;
strncpy( vdata, hint, NOTESZ + 1 ) ;
xfree(hint);
xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp)
{
char *enclosure = "";
+ geocache_data *gc_data = NULL;
if (0 == strcmp(fmp->printfc, "\"%s\"")) {
enclosure = "\"";
case XT_ISO_TIME_MS:
wpt->creation_time = xml_parse_time(s, &wpt->microseconds);
break;
- case XT_GEOCACHE_LAST_FOUND:
- wpt->gc_data.last_found = yyyymmdd_to_time(s);
+ case XT_GEOCACHE_LAST_FOUND:
+ waypt_alloc_gc_data(wpt)->last_found = yyyymmdd_to_time(s);
break;
/* GEOCACHING STUFF ***************************************************/
case XT_GEOCACHE_DIFF:
/* Geocache Difficulty as an int */
- wpt->gc_data.diff = atof(s) * 10;
+ waypt_alloc_gc_data(wpt)->diff = atof(s) * 10;
break;
case XT_GEOCACHE_TERR:
/* Geocache Terrain as an int */
- wpt->gc_data.terr = atof(s) * 10;
+ waypt_alloc_gc_data(wpt)->terr = atof(s) * 10;
break;
case XT_GEOCACHE_TYPE:
/* Geocache Type */
- wpt->gc_data.type = gs_mktype(s);
+ waypt_alloc_gc_data(wpt)->type = gs_mktype(s);
break;
case XT_GEOCACHE_CONTAINER:
- wpt->gc_data.container = gs_mkcont(s);
+ waypt_alloc_gc_data(wpt)->container = gs_mkcont(s);
break;
case XT_GEOCACHE_HINT:
- wpt->gc_data.hint = csv_stringtrim(s, "", 0);
+ waypt_alloc_gc_data(wpt)->hint = csv_stringtrim(s, "", 0);
break;
case XT_GEOCACHE_PLACER:
- wpt->gc_data.placer = csv_stringtrim(s, "", 0);
+ waypt_alloc_gc_data(wpt)->placer = csv_stringtrim(s, "", 0);
break;
case XT_GEOCACHE_ISAVAILABLE:
+ gc_data = waypt_alloc_gc_data(wpt);
if ( case_ignore_strcmp(csv_stringtrim(s, "", 0), "False") == 0 )
- wpt->gc_data.is_available = status_false;
+ gc_data->is_available = status_false;
else if ( case_ignore_strcmp(csv_stringtrim(s, "", 0), "True") == 0 )
- wpt->gc_data.is_available = status_true;
+ gc_data->is_available = status_true;
else
- wpt->gc_data.is_available = status_unknown;
+ gc_data->is_available = status_unknown;
break;
case XT_GEOCACHE_ISARCHIVED:
+ gc_data = waypt_alloc_gc_data(wpt);
if ( case_ignore_strcmp(csv_stringtrim(s, "", 0), "False") == 0 )
- wpt->gc_data.is_archived = status_false;
+ gc_data->is_archived = status_false;
else if ( case_ignore_strcmp(csv_stringtrim(s, "", 0), "True") == 0 )
- wpt->gc_data.is_archived = status_true;
+ gc_data->is_archived = status_true;
else
- wpt->gc_data.is_archived = status_unknown;
+ gc_data->is_archived = status_unknown;
break;
/* GPS STUFF *******************************************************/
wpt->microseconds, XML_LONG_TIME);
break;
case XT_GEOCACHE_LAST_FOUND:
- writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->gc_data.last_found));
+ writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->gc_data->last_found));
break;
/* GEOCACHE STUFF **************************************************/
case XT_GEOCACHE_DIFF:
/* Geocache Difficulty as a double */
- writebuff(buff, fmp->printfc, wpt->gc_data.diff / 10.0);
- field_is_unknown = !wpt->gc_data.diff;
+ writebuff(buff, fmp->printfc, wpt->gc_data->diff / 10.0);
+ field_is_unknown = !wpt->gc_data->diff;
break;
case XT_GEOCACHE_TERR:
/* Geocache Terrain as a double */
- writebuff(buff, fmp->printfc, wpt->gc_data.terr / 10.0);
- field_is_unknown = !wpt->gc_data.terr;
+ writebuff(buff, fmp->printfc, wpt->gc_data->terr / 10.0);
+ field_is_unknown = !wpt->gc_data->terr;
break;
case XT_GEOCACHE_CONTAINER:
/* Geocache Container */
- writebuff(buff, fmp->printfc, gs_get_container(wpt->gc_data.container));
- field_is_unknown = wpt->gc_data.container == gc_unknown;
+ writebuff(buff, fmp->printfc, gs_get_container(wpt->gc_data->container));
+ field_is_unknown = wpt->gc_data->container == gc_unknown;
break;
case XT_GEOCACHE_TYPE:
/* Geocache Type */
- writebuff(buff, fmp->printfc, gs_get_cachetype(wpt->gc_data.type));
- field_is_unknown = wpt->gc_data.type == gt_unknown;
+ writebuff(buff, fmp->printfc, gs_get_cachetype(wpt->gc_data->type));
+ field_is_unknown = wpt->gc_data->type == gt_unknown;
break;
case XT_GEOCACHE_HINT:
- writebuff(buff, fmp->printfc, NONULL(wpt->gc_data.hint));
- field_is_unknown = !wpt->gc_data.hint;
+ writebuff(buff, fmp->printfc, NONULL(wpt->gc_data->hint));
+ field_is_unknown = !wpt->gc_data->hint;
break;
case XT_GEOCACHE_PLACER:
- writebuff(buff, fmp->printfc, NONULL(wpt->gc_data.placer));
- field_is_unknown = !wpt->gc_data.placer;
+ writebuff(buff, fmp->printfc, NONULL(wpt->gc_data->placer));
+ field_is_unknown = !wpt->gc_data->placer;
break;
case XT_GEOCACHE_ISAVAILABLE:
- if ( wpt->gc_data.is_available == status_false )
+ if ( wpt->gc_data->is_available == status_false )
writebuff(buff, fmp->printfc, "False");
- else if ( wpt->gc_data.is_available == status_true )
+ else if ( wpt->gc_data->is_available == status_true )
writebuff(buff, fmp->printfc, "True");
else
writebuff(buff, fmp->printfc, "Unknown");
break;
case XT_GEOCACHE_ISARCHIVED:
- if ( wpt->gc_data.is_archived == status_false )
+ if ( wpt->gc_data->is_archived == status_false )
writebuff(buff, fmp->printfc, "False");
- else if ( wpt->gc_data.is_archived == status_true )
+ else if ( wpt->gc_data->is_archived == status_true )
writebuff(buff, fmp->printfc, "True");
else
writebuff(buff, fmp->printfc, "Unknown");
unsigned char heartrate; /* Beats/min. likely to get moved to fs. */
unsigned char cadence; /* revolutions per minute */
float temperature; /* Degrees celsius */
- geocache_data gc_data;
+ const geocache_data *gc_data;
format_specific_data *fs;
session_t *session; /* pointer to a session struct */
void *extra_data; /* Extra data added by, say, a filter. */
waypoint * find_waypt_by_name(const char *name);
void waypt_backup(signed int *count, queue **head_bak);
void waypt_restore(signed int count, queue *head_bak);
+geocache_data *waypt_alloc_gc_data(waypoint *wpt);
route_head *route_head_alloc(void);
void route_add (waypoint *);
const wpt_ptr *wa = (wpt_ptr *)a;
const wpt_ptr *wb = (wpt_ptr *)b;
- if ( wa->wpt->gc_data.exported < wb->wpt->gc_data.exported ) {
+ if ( wa->wpt->gc_data->exported < wb->wpt->gc_data->exported ) {
return 1;
- } else if ( wa->wpt->gc_data.exported > wb->wpt->gc_data.exported ) {
+ } else if ( wa->wpt->gc_data->exported > wb->wpt->gc_data->exported ) {
return -1;
}
get_gc_info(waypoint *wpt)
{
if (global_opts.smart_names) {
- if (wpt->gc_data.type == gt_virtual) return "V ";
- if (wpt->gc_data.type == gt_unknown) return "? ";
- if (wpt->gc_data.type == gt_multi) return "Mlt ";
- if (wpt->gc_data.type == gt_earth) return "EC ";
- if (wpt->gc_data.type == gt_event) return "Ev ";
- if (wpt->gc_data.container == gc_micro) return "M ";
- if (wpt->gc_data.container == gc_small) return "S ";
+ if (wpt->gc_data->type == gt_virtual) return "V ";
+ if (wpt->gc_data->type == gt_unknown) return "? ";
+ if (wpt->gc_data->type == gt_multi) return "Mlt ";
+ if (wpt->gc_data->type == gt_earth) return "EC ";
+ if (wpt->gc_data->type == gt_event) return "Ev ";
+ if (wpt->gc_data->container == gc_micro) return "M ";
+ if (wpt->gc_data->container == gc_small) return "S ";
}
return "";
}
memcpy(way[i]->cmnt, wpt->description, strlen(wpt->description));
} else {
if (global_opts.smart_names &&
- wpt->gc_data.diff && wpt->gc_data.terr) {
+ wpt->gc_data->diff && wpt->gc_data->terr) {
#if 0
xasprintf(&src, "%s %s", &wpt->shortname[2], src);
#endif
snprintf(obuf, sizeof(obuf), "%s%d/%d %s",
get_gc_info(wpt),
- wpt->gc_data.diff, wpt->gc_data.terr,
+ wpt->gc_data->diff, wpt->gc_data->terr,
src);
memcpy(way[i]->cmnt, obuf, strlen(obuf));
} else {
wpt->notes = xstrappend(wpt->notes, recdata);
} else
if (!strncmp("diff", rec->dbfld[i].fldname,4)) {
- wpt->gc_data.diff = 10 * atof(recdata);
+ waypt_alloc_gc_data(wpt)->diff = 10 * atof(recdata);
} else
if (!strncmp("terr", rec->dbfld[i].fldname,4)) {
- wpt->gc_data.terr = 10 * atof(recdata);
+ waypt_alloc_gc_data(wpt)->terr = 10 * atof(recdata);
}
break;
#if 0
(int) wpt->longitude));
gcdb_add_to_rec(rec, "lon2", RECTYPE_TEXT, tbuf);
- if (wpt->gc_data.diff) {
- sprintf(tbuf, "%f", wpt->gc_data.diff / 10.0);
+ if (wpt->gc_data->diff) {
+ sprintf(tbuf, "%f", wpt->gc_data->diff / 10.0);
gcdb_add_to_rec(rec, "diff", RECTYPE_TEXT, tbuf);
}
- if (wpt->gc_data.terr) {
- sprintf(tbuf, "%f", wpt->gc_data.terr / 10.0);
+ if (wpt->gc_data->terr) {
+ sprintf(tbuf, "%f", wpt->gc_data->terr / 10.0);
gcdb_add_to_rec(rec, "terr", RECTYPE_TEXT, tbuf);
}
wpt_tmp->description = xstrappend(wpt_tmp->description,args);
s = xstrrstr(wpt_tmp->description, " by ");
if (s) {
- wpt_tmp->gc_data.placer = xstrdup(s + 4);
+ waypt_alloc_gc_data(wpt_tmp)->placer = xstrdup(s + 4);
if (nuke_placer) {
*s = '\0';
else if (strstr(desc, "unk")) return 48;
else if (strstr(desc, "cam")) return 49;
- switch (wpt->gc_data.type) {
+ switch (wpt->gc_data->type) {
case gt_traditional: return 43;
case gt_multi: return 44;
case gt_locationless: return 45;
char *gs = NULL, *tmp1, *tmp2, *tmp3;
char tbuf[10240];
- if (!wpt->gc_data.terr) {
+ if (!wpt->gc_data->terr) {
return NULL;
}
- snprintf(tbuf, sizeof(tbuf), "\n%s by %s\n\n", gs_get_cachetype(wpt->gc_data.type), wpt->gc_data.placer);
+ snprintf(tbuf, sizeof(tbuf), "\n%s by %s\n\n", gs_get_cachetype(wpt->gc_data->type), wpt->gc_data->placer);
gs = xstrappend(gs, tbuf);
/*
/*
* 3 May 06: Added container type
*/
- snprintf(tbuf, sizeof(tbuf), "Container: %s\nDifficulty: %3.1f\nTerrain: %3.1f\n\n", gs_get_container(wpt->gc_data.container), wpt->gc_data.diff/10.0, wpt->gc_data.terr/10.0);
+ snprintf(tbuf, sizeof(tbuf), "Container: %s\nDifficulty: %3.1f\nTerrain: %3.1f\n\n", gs_get_container(wpt->gc_data->container), wpt->gc_data->diff/10.0, wpt->gc_data->terr/10.0);
gs = xstrappend(gs, tbuf);
- tmp1 = strip_html(&wpt->gc_data.desc_short);
- tmp2 = strip_html(&wpt->gc_data.desc_long);
+ tmp1 = strip_html(&wpt->gc_data->desc_short);
+ tmp2 = strip_html(&wpt->gc_data->desc_long);
gs = xstrappend(gs, tmp1);
gs = xstrappend(gs, tmp2);
- tmp3 = rot13(wpt->gc_data.hint);
+ tmp3 = rot13(wpt->gc_data->hint);
snprintf(tbuf, sizeof(tbuf), "\n\nHint: %s\n", tmp3);
gs = xstrappend(gs, tbuf);
tag_gs_cache(const char **attrv)
{
const char **avp;
+ geocache_data *gc_data = waypt_alloc_gc_data(wpt_tmp);
for (avp = &attrv[0]; *avp; avp+=2) {
if (strcmp(avp[0], "id") == 0) {
- wpt_tmp->gc_data.id = atoi(avp[1]);
+ gc_data->id = atoi(avp[1]);
} else if (strcmp(avp[0], "available") == 0) {
if (case_ignore_strcmp(avp[1], "True") == 0) {
- wpt_tmp->gc_data.is_available = status_true;
+ gc_data->is_available = status_true;
}
else if (case_ignore_strcmp(avp[1], "False") == 0) {
- wpt_tmp->gc_data.is_available = status_false;
+ gc_data->is_available = status_false;
}
} else if (strcmp(avp[0], "archived") == 0) {
if (case_ignore_strcmp(avp[1], "True") == 0) {
- wpt_tmp->gc_data.is_archived = status_true;
+ gc_data->is_archived = status_true;
}
else if (case_ignore_strcmp(avp[1], "False") == 0) {
- wpt_tmp->gc_data.is_archived = status_false;
+ gc_data->is_archived = status_false;
}
}
}
break;
case tt_cache_placer:
if (*attr && (0 == strcmp(attr[0], "id"))) {
- wpt_tmp->gc_data.placer_id = atoi(attr[1]);
+ waypt_alloc_gc_data(wpt_tmp)->placer_id = atoi(attr[1]);
}
default:
break;
wpt_tmp->notes = xstrdup(cdatastrp);
break;
case tt_cache_container:
- wpt_tmp->gc_data.container = gs_mkcont(cdatastrp);
+ waypt_alloc_gc_data(wpt_tmp)->container = gs_mkcont(cdatastrp);
break;
case tt_cache_type:
- wpt_tmp->gc_data.type = gs_mktype(cdatastrp);
+ waypt_alloc_gc_data(wpt_tmp)->type = gs_mktype(cdatastrp);
break;
case tt_cache_difficulty:
sscanf(cdatastrp, "%f", &x);
- wpt_tmp->gc_data.diff = x * 10;
+ waypt_alloc_gc_data(wpt_tmp)->diff = x * 10;
break;
case tt_cache_hint:
rtrim(cdatastrp);
if (cdatastrp[0]) {
- wpt_tmp->gc_data.hint = xstrdup(cdatastrp);
+ waypt_alloc_gc_data(wpt_tmp)->hint = xstrdup(cdatastrp);
}
break;
case tt_cache_desc_long:
rtrim(cdatastrp);
if (cdatastrp[0]) {
- wpt_tmp->gc_data.desc_long.is_html = cache_descr_is_html;
- wpt_tmp->gc_data.desc_long.utfstring = xstrdup(cdatastrp);
+ geocache_data *gc_data = waypt_alloc_gc_data(wpt_tmp);
+ gc_data->desc_long.is_html = cache_descr_is_html;
+ gc_data->desc_long.utfstring = xstrdup(cdatastrp);
}
break;
case tt_cache_desc_short:
rtrim(cdatastrp);
if (cdatastrp[0]) {
- wpt_tmp->gc_data.desc_short.is_html = cache_descr_is_html;
- wpt_tmp->gc_data.desc_short.utfstring = xstrdup(cdatastrp);
+ geocache_data *gc_data = waypt_alloc_gc_data(wpt_tmp);
+ gc_data->desc_short.is_html = cache_descr_is_html;
+ gc_data->desc_short.utfstring = xstrdup(cdatastrp);
}
break;
case tt_cache_terrain:
sscanf(cdatastrp, "%f", &x);
- wpt_tmp->gc_data.terr = x * 10;
+ waypt_alloc_gc_data(wpt_tmp)->terr = x * 10;
break;
case tt_cache_placer:
- wpt_tmp->gc_data.placer = xstrdup(cdatastrp);
+ waypt_alloc_gc_data(wpt_tmp)->placer = xstrdup(cdatastrp);
break;
case tt_cache_log_date:
gc_log_date = xml_parse_time( cdatastrp, NULL );
*/
case tt_cache_log_type:
if ((0 == strcmp(cdatastrp, "Found it")) &&
- (0 == wpt_tmp->gc_data.last_found)) {
- wpt_tmp->gc_data.last_found = gc_log_date;
+ (0 == wpt_tmp->gc_data->last_found)) {
+ waypt_alloc_gc_data(wpt_tmp)->last_found = gc_log_date;
}
gc_log_date = 0;
break;
if ( tag->child ) {
fprint_xml_chain(tag->child, wpt);
}
- if ( wpt && wpt->gc_data.exported &&
+ if ( wpt && wpt->gc_data->exported &&
strcmp(tag->tagname, "groundspeak:cache" ) == 0 ) {
- xml_write_time( ofd, wpt->gc_data.exported, 0,
+ xml_write_time( ofd, wpt->gc_data->exported, 0,
"groundspeak:exported" );
}
gbfprintf( ofd, "</%s>\n", tag->tagname);
else {
gbfprintf(file_out, "%s", wpt->description);
}
- if (wpt->gc_data.placer) {
- gbfprintf(file_out, " by %s", wpt->gc_data.placer);
+ if (wpt->gc_data->placer) {
+ gbfprintf(file_out, " by %s", wpt->gc_data->placer);
}
}
gbfprintf(file_out, "</p></td>\n");
gbfprintf (file_out, "<td align=\"right\">");
- if (wpt->gc_data.terr) {
+ if (wpt->gc_data->terr) {
gbfprintf (file_out, "<p class=\"gpsbabelcacheinfo\">%d%s / %d%s<br>\n",
- (int)(wpt->gc_data.diff / 10), (wpt->gc_data.diff%10)?"½":"",
- (int)(wpt->gc_data.terr / 10), (wpt->gc_data.terr%10)?"½":"" );
+ (int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10)?"½":"",
+ (int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10)?"½":"" );
gbfprintf(file_out, "%s / %s</p>",
- gs_get_cachetype(wpt->gc_data.type),
- gs_get_container(wpt->gc_data.container));
+ gs_get_cachetype(wpt->gc_data->type),
+ gs_get_container(wpt->gc_data->container));
}
gbfprintf(file_out, "</td></tr>\n");
gbfprintf(file_out, "<tr><td colspan=\"2\">");
- if (wpt->gc_data.desc_short.utfstring) {
- char *tmpstr = strip_nastyhtml(wpt->gc_data.desc_short.utfstring);
+ if (wpt->gc_data->desc_short.utfstring) {
+ char *tmpstr = strip_nastyhtml(wpt->gc_data->desc_short.utfstring);
gbfprintf (file_out, "<p class=\"gpsbabeldescshort\">%s</p>\n", tmpstr );
xfree( tmpstr );
}
- if (wpt->gc_data.desc_long.utfstring) {
- char *tmpstr = strip_nastyhtml(wpt->gc_data.desc_long.utfstring);
+ if (wpt->gc_data->desc_long.utfstring) {
+ char *tmpstr = strip_nastyhtml(wpt->gc_data->desc_long.utfstring);
gbfprintf (file_out, "<p class=\"gpsbabeldesclong\">%s</p>\n", tmpstr );
xfree( tmpstr );
}
- if (wpt->gc_data.hint) {
+ if (wpt->gc_data->hint) {
char *hint = NULL;
if ( html_encrypt )
- hint = rot13( wpt->gc_data.hint );
+ hint = rot13( wpt->gc_data->hint );
else
- hint = xstrdup( wpt->gc_data.hint );
+ hint = xstrdup( wpt->gc_data->hint );
gbfprintf (file_out, "<p class=\"gpsbabelhint\"><strong>Hint:</strong> %s</p>\n", hint);
xfree( hint );
}
/* This could be done so much better in C99 with designated
* initializers...
*/
- switch (waypointp->gc_data.type) {
+ switch (waypointp->gc_data->type) {
case gt_traditional: icon = "2.png"; break;
case gt_multi: icon = "3.png"; break;
case gt_virtual: icon = "4.png"; break;
{
const char *cont;
- switch (waypointp->gc_data.container) {
+ switch (waypointp->gc_data->container) {
case gc_micro: cont="micro"; break;
case gc_regular: cont="regular"; break;
case gc_large: cont="large"; break;
xfree(p);
}
- if (waypointp->gc_data.placer) {
- p = xml_entitize(waypointp->gc_data.placer);
+ if (waypointp->gc_data->placer) {
+ p = xml_entitize(waypointp->gc_data->placer);
kml_write_xml(0, "<Data name=\"gc_placer\"><value>%s</value></Data>\n", p);
xfree(p);
}
- kml_write_xml(0, "<Data name=\"gc_placer_id\"><value>%d</value></Data>\n", waypointp->gc_data.placer_id);
+ kml_write_xml(0, "<Data name=\"gc_placer_id\"><value>%d</value></Data>\n", waypointp->gc_data->placer_id);
- kml_write_xml(0, "<Data name=\"gc_diff_stars\"><value>%s</value></Data>\n", kml_gc_mkstar(waypointp->gc_data.diff));
- kml_write_xml(0, "<Data name=\"gc_terr_stars\"><value>%s</value></Data>\n", kml_gc_mkstar(waypointp->gc_data.terr));
+ kml_write_xml(0, "<Data name=\"gc_diff_stars\"><value>%s</value></Data>\n", kml_gc_mkstar(waypointp->gc_data->diff));
+ kml_write_xml(0, "<Data name=\"gc_terr_stars\"><value>%s</value></Data>\n", kml_gc_mkstar(waypointp->gc_data->terr));
kml_write_xml(0, "<Data name=\"gc_cont_icon\"><value>%s</value></Data>\n", kml_lookup_gc_container(waypointp));
// Highlight any issues with the cache, such as temp unavail
// or archived.
kml_write_xml(0, "<Data name=\"gc_issues\"><value>");
- if (waypointp->gc_data.is_archived == status_true) {
+ if (waypointp->gc_data->is_archived == status_true) {
kml_write_xml(0, "<font color=\"red\">This cache has been archived.</font><br/>\n");
- } else if (waypointp->gc_data.is_available == status_false) {
+ } else if (waypointp->gc_data->is_available == status_false) {
kml_write_xml(0, "<font color=\"red\">This cache is temporarily unavailable.</font><br/>\n");
}
kml_write_xml(0, "</value></Data>\n");
- kml_write_xml(0, "<Data name=\"gc_type\"><value>%s</value></Data>\n", gs_get_cachetype(waypointp->gc_data.type));
- kml_write_xml(0, "<Data name=\"gc_short_desc\"><value><![CDATA[%s]]></value></Data>\n", waypointp->gc_data.desc_short.utfstring ? waypointp->gc_data.desc_short.utfstring : "");
- kml_write_xml(0, "<Data name=\"gc_long_desc\"><value><![CDATA[%s]]></value></Data>\n", waypointp->gc_data.desc_long.utfstring ? waypointp->gc_data.desc_long.utfstring : "");
+ kml_write_xml(0, "<Data name=\"gc_type\"><value>%s</value></Data>\n", gs_get_cachetype(waypointp->gc_data->type));
+ kml_write_xml(0, "<Data name=\"gc_short_desc\"><value><![CDATA[%s]]></value></Data>\n", waypointp->gc_data->desc_short.utfstring ? waypointp->gc_data->desc_short.utfstring : "");
+ kml_write_xml(0, "<Data name=\"gc_long_desc\"><value><![CDATA[%s]]></value></Data>\n", waypointp->gc_data->desc_long.utfstring ? waypointp->gc_data->desc_long.utfstring : "");
kml_write_xml(-1, "</ExtendedData>\n");
}
#endif
- if (waypointp->gc_data.diff && waypointp->gc_data.terr) {
+ if (waypointp->gc_data->diff && waypointp->gc_data->terr) {
kml_geocache_pr(waypointp);
return;
}
SymbolId = lowranceusr_find_icon_number_from_desc(wpt->icon_descr);
}
/* If the waypoint is archived or disabled, use a "disabled" icon instead. */
- if ( (wpt->gc_data.is_archived==status_true) || (wpt->gc_data.is_available==status_false) ) {
+ if ( (wpt->gc_data->is_archived==status_true) || (wpt->gc_data->is_available==status_false) ) {
SymbolId = lowranceusr_find_icon_number_from_desc("Disabled Cache");
}
* For some reason, Magellan used exactly the GPX spellings of
* everything except this one...
*/
- if (waypointp->gc_data.type == gt_suprise) {
+ if (waypointp->gc_data->type == gt_suprise) {
ctype = "Mystery Cache";
} else {
- ctype = gs_get_cachetype(waypointp->gc_data.type);
+ ctype = gs_get_cachetype(waypointp->gc_data->type);
}
placeddate = maggeo_fmtdate(waypointp->creation_time);
- lfounddate = maggeo_fmtdate(waypointp->gc_data.last_found);
+ lfounddate = maggeo_fmtdate(waypointp->gc_data->last_found);
cname = mkshort(desc_handle, waypointp->notes ? waypointp->notes : waypointp->description);
- placer = waypointp->gc_data.placer;
+ placer = waypointp->gc_data->placer;
/*
* As of this writing on 05/04, the firmware in the units will
append(obuf, shortname);
append(obuf, cname);
append(obuf, placer);
- append(obuf, waypointp->gc_data.hint);
+ append(obuf, waypointp->gc_data->hint);
append(obuf, ctype);
append(obuf, placeddate);
append(obuf, lfounddate);
- if (waypointp->gc_data.diff/10.0)
+ if (waypointp->gc_data->diff/10.0)
sprintf(obuf + strlen(obuf), ",%3.1f",
- waypointp->gc_data.diff/10.0);
+ waypointp->gc_data->diff/10.0);
else
strcat(obuf, ",");
- if (waypointp->gc_data.terr/10.0)
+ if (waypointp->gc_data->terr/10.0)
sprintf(obuf + strlen(obuf), ",%3.1f",
- waypointp->gc_data.terr/10.0);
+ waypointp->gc_data->terr/10.0);
else
strcat(obuf, ",");
owpt = mag_cleanse(owpt);
if (global_opts.smart_icons &&
- waypointp->gc_data.diff && waypointp->gc_data.terr) {
- sprintf(ofmtdesc, "%d/%d %s", waypointp->gc_data.diff,
- waypointp->gc_data.terr, odesc);
+ waypointp->gc_data->diff && waypointp->gc_data->terr) {
+ sprintf(ofmtdesc, "%d/%d %s", waypointp->gc_data->diff,
+ waypointp->gc_data->terr, odesc);
odesc = mag_cleanse(ofmtdesc);
} else {
odesc = mag_cleanse(odesc);
* which contains placer name, diff, terr, and generally way
* more stuff than should be in any one field...
*/
- if (wpt->gc_data.diff && wpt->gc_data.terr &&
+ if (wpt->gc_data->diff && wpt->gc_data->terr &&
wpt->notes && wpt->notes[0]) {
return mkshort(h, wpt->notes);
}
attr = xml_convert_attrs_to_char_string(xml_attr);
if (0 == strcmp(el, "CacheDetails")) {
const char **ap;
+ geocache_data *gc_data;
wpt_tmp = waypt_new();
+ gc_data = waypt_alloc_gc_data(wpt_tmp);
+
for (ap = attr; *ap; ap+=2) {
if (0 == strcmp(ap[0], "cache_id")) {
wpt_tmp->shortname = xstrdup(ap[1]);
if (0 == strcmp(ap[0], "difficulty")) {
float x;
sscanf(ap[1], "%f", &x);
- wpt_tmp->gc_data.diff = x * 10;
+ gc_data->diff = x * 10;
} else
if (0 == strcmp(ap[0], "terrain")) {
float x;
sscanf(ap[1], "%f", &x);
- wpt_tmp->gc_data.terr = x * 10;
+ gc_data->terr = x * 10;
} else
if (0 == strcmp(ap[0], "cache_type")) {
static char buf[512];
- wpt_tmp->gc_data.type = nc_mktype(ap[1]);
+ gc_data->type = nc_mktype(ap[1]);
if (!strcmp(ap[1], "normal"))
wpt_tmp->icon_descr = "Geocache-regular";
else if (!strcmp(ap[1], "multi-part"))
}
} else
if (0 == strcmp(ap[0], "cache_size")) {
- wpt_tmp->gc_data.container = nc_mkcont(ap[1]);
+ gc_data->container = nc_mkcont(ap[1]);
} else
if (0 == strcmp(ap[0], "description")) {
- wpt_tmp->gc_data.desc_long.is_html = 1;
- wpt_tmp->gc_data.desc_long.utfstring = xstrdup(ap[1]);
+ gc_data->desc_long.is_html = 1;
+ gc_data->desc_long.utfstring = xstrdup(ap[1]);
} else
if (0 == strcmp(ap[0], "comments")) {
- wpt_tmp->gc_data.desc_short.is_html = 1;
- wpt_tmp->gc_data.desc_short.utfstring = xstrdup(ap[1]);
+ gc_data->desc_short.is_html = 1;
+ gc_data->desc_short.utfstring = xstrdup(ap[1]);
}
}
waypt_add(wpt_tmp);
if (strcmp(wpt->description, wpt->shortname)) {
docprintf(10+strlen(wpt->description), "%s\n", wpt->description);
}
- if (wpt->gc_data.terr) {
+ if (wpt->gc_data->terr) {
- docprintf (100, "%s/%s\n", gs_get_cachetype(wpt->gc_data.type),
- gs_get_container(wpt->gc_data.container));
+ docprintf (100, "%s/%s\n", gs_get_cachetype(wpt->gc_data->type),
+ gs_get_container(wpt->gc_data->container));
- if (wpt->gc_data.desc_short.utfstring) {
- char *stripped_html = strip_html(&wpt->gc_data.desc_short);
+ if (wpt->gc_data->desc_short.utfstring) {
+ char *stripped_html = strip_html(&wpt->gc_data->desc_short);
docprintf (10+strlen(stripped_html), "\n%s\n", stripped_html);
xfree(stripped_html);
}
- if (wpt->gc_data.desc_long.utfstring) {
- char *stripped_html = strip_html(&wpt->gc_data.desc_long);
+ if (wpt->gc_data->desc_long.utfstring) {
+ char *stripped_html = strip_html(&wpt->gc_data->desc_long);
docprintf (10+strlen(stripped_html), "\n%s\n", stripped_html);
xfree(stripped_html);
}
- if (wpt->gc_data.hint) {
+ if (wpt->gc_data->hint) {
char *hint = NULL;
if ( palm_encrypt )
- hint = rot13( wpt->gc_data.hint );
+ hint = rot13( wpt->gc_data->hint );
else
- hint = xstrdup( wpt->gc_data.hint );
+ hint = xstrdup( wpt->gc_data->hint );
docprintf (10+strlen(hint), "\nHint: %s\n", hint);
xfree( hint );
}
90.0 - (be_read32(&rec->latitude) / 1000000.0);
wpt_tmp->shortname = xstrdup(rec->name);
- wpt_tmp->gc_data.type =
+ waypt_alloc_gc_data(wpt_tmp)->type =
icon_to_wpt(be_read16(&rec->icon_bitmap));
waypt_add(wpt_tmp);
else {
rec->name[0] = '\0';
}
- be_write16(&rec->icon_bitmap, wpt_to_icon(wpt->gc_data.type));
+ be_write16(&rec->icon_bitmap, wpt_to_icon(wpt->gc_data->type));
be_write32(&rec->note_id, 0);
rec->name_scale = DEFAULT_NAME_SCALE;
rec->icon_scale = DEFAULT_ICON_SCALE;
const waypoint *x2 = (waypoint *)b;
switch (sort_mode) {
- case sm_gcid: return x1->gc_data.id - x2->gc_data.id;
+ case sm_gcid: return x1->gc_data->id - x2->gc_data->id;
case sm_shortname: return strcmp (x1->shortname, x2->shortname);
case sm_description: return strcmp (x1->description, x2->description);
case sm_time: return x1->creation_time - x2->creation_time;
if (strcmp(wpt->description, wpt->shortname)) {
gbfprintf(file_out, "%s", wpt->description);
- if (wpt->gc_data.placer)
- gbfprintf(file_out, " by %s", wpt->gc_data.placer);
+ if (wpt->gc_data->placer)
+ gbfprintf(file_out, " by %s", wpt->gc_data->placer);
}
- if (wpt->gc_data.terr) {
+ if (wpt->gc_data->terr) {
gbfprintf(file_out, " - %s / %s - (%d%s / %d%s)\n",
- gs_get_cachetype(wpt->gc_data.type), gs_get_container(wpt->gc_data.container),
- (int)(wpt->gc_data.diff / 10), (wpt->gc_data.diff%10)?".5":"",
- (int)(wpt->gc_data.terr / 10), (wpt->gc_data.terr%10)?".5":"" );
- if (wpt->gc_data.desc_short.utfstring) {
- char *stripped_html = strip_html(&wpt->gc_data.desc_short);
+ gs_get_cachetype(wpt->gc_data->type), gs_get_container(wpt->gc_data->container),
+ (int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10)?".5":"",
+ (int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10)?".5":"" );
+ if (wpt->gc_data->desc_short.utfstring) {
+ char *stripped_html = strip_html(&wpt->gc_data->desc_short);
gbfprintf (file_out, "\n%s\n", stripped_html);
xfree(stripped_html);
}
- if (wpt->gc_data.desc_long.utfstring) {
- char *stripped_html = strip_html(&wpt->gc_data.desc_long);
+ if (wpt->gc_data->desc_long.utfstring) {
+ char *stripped_html = strip_html(&wpt->gc_data->desc_long);
gbfprintf (file_out, "\n%s\n", stripped_html);
xfree(stripped_html);
}
- if (wpt->gc_data.hint) {
+ if (wpt->gc_data->hint) {
char *hint = NULL;
if ( txt_encrypt )
- hint = rot13( wpt->gc_data.hint );
+ hint = rot13( wpt->gc_data->hint );
else
- hint = xstrdup( wpt->gc_data.hint );
+ hint = xstrdup( wpt->gc_data->hint );
gbfprintf (file_out, "\nHint: %s\n", hint);
xfree( hint );
}
char desc_field [256];
write_char( f, 2 );
if (global_opts.smart_names &&
- blocks->start[i].wpt->gc_data.diff &&
- blocks->start[i].wpt->gc_data.terr) {
+ blocks->start[i].wpt->gc_data->diff &&
+ blocks->start[i].wpt->gc_data->terr) {
snprintf(desc_field,sizeof(desc_field),"%s(t%ud%u)%s(type%dcont%d)",blocks->start[i].wpt->description,
- blocks->start[i].wpt->gc_data.terr/10,
- blocks->start[i].wpt->gc_data.diff/10,
+ blocks->start[i].wpt->gc_data->terr/10,
+ blocks->start[i].wpt->gc_data->diff/10,
blocks->start[i].wpt->shortname,
- (int) blocks->start[i].wpt->gc_data.type,
- (int) blocks->start[i].wpt->gc_data.container);
+ (int) blocks->start[i].wpt->gc_data->type,
+ (int) blocks->start[i].wpt->gc_data->container);
//Unfortunately enums mean we get numbers for cache type and container.
} else {
snprintf(desc_field, sizeof(desc_field), "%s",
* For icons, type overwrites container. So a multi-micro will
* get the icons for "multi".
*/
- switch (waypointp->gc_data.type) {
+ switch (waypointp->gc_data->type) {
case gt_virtual:
return "Virtual cache";
case gt_multi:
break;
}
- switch (waypointp->gc_data.container) {
+ switch (waypointp->gc_data->container) {
case gc_micro:
return "Micro-Cache";
break;
break;
}
- if (waypointp->gc_data.diff > 1) {
+ if (waypointp->gc_data->diff > 1) {
return "Geocache";
}
}
gbfprintf(file_out, "NOTE:");
- vcf_print_utf(&wpt->gc_data.desc_short);
+ vcf_print_utf(&wpt->gc_data->desc_short);
gbfprintf(file_out, "\\n");
- vcf_print_utf(&wpt->gc_data.desc_long);
+ vcf_print_utf(&wpt->gc_data->desc_long);
gbfprintf(file_out, "\\n\\nHINT:\\n");
if (vcf_encrypt) {
- char *s = rot13(wpt->gc_data.hint);
+ char *s = rot13(wpt->gc_data->hint);
vcf_print(s);
xfree(s);
} else {
- vcf_print(wpt->gc_data.hint);
+ vcf_print(wpt->gc_data->hint);
}
gbfprintf(file_out, "\nEND:VCARD\n");
static unsigned int waypt_ct;
static short_handle mkshort_handle;
int geocaches_present;
+static geocache_data empty_gc_data = {};
void
waypt_init(void)
}
if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic)
tmp->icon_descr = xstrdup(wpt->icon_descr);
- if (wpt->gc_data.desc_short.utfstring) {
- tmp->gc_data.desc_short.utfstring =
- xstrdup(wpt->gc_data.desc_short.utfstring);
- }
- if (wpt->gc_data.desc_long.utfstring) {
- tmp->gc_data.desc_long.utfstring =
- xstrdup(wpt->gc_data.desc_long.utfstring);
+
+ if (wpt->gc_data != &empty_gc_data) {
+ geocache_data *gc_data = xmalloc(sizeof(*gc_data));
+ tmp->gc_data = (const geocache_data *)gc_data;
+
+ memcpy(gc_data, wpt->gc_data, sizeof(*gc_data));
+ if (wpt->gc_data->desc_short.utfstring) {
+ gc_data->desc_short.utfstring =
+ xstrdup(wpt->gc_data->desc_short.utfstring);
+ }
+ if (wpt->gc_data->desc_long.utfstring) {
+ gc_data->desc_long.utfstring =
+ xstrdup(wpt->gc_data->desc_long.utfstring);
+ }
+ if (wpt->gc_data->placer) {
+ gc_data->placer = xstrdup(wpt->gc_data->placer);
+ }
+ if (wpt->gc_data->hint) {
+ gc_data->hint = xstrdup(wpt->gc_data->hint);
+ }
}
- if (wpt->gc_data.placer) {
- tmp->gc_data.placer = xstrdup(wpt->gc_data.placer);
- }
- if (wpt->gc_data.hint) {
- tmp->gc_data.hint = xstrdup(wpt->gc_data.hint);
- }
/*
* It's important that this duplicated waypoint not appear
* all waypoints may have this and a few other pitfalls, but it's
* an easy and fast test here.
*/
- if (wpt->gc_data.diff && wpt->gc_data.terr) {
+ if (wpt->gc_data->diff && wpt->gc_data->terr) {
geocaches_present = 1;
}
}
wpt->fix = fix_unknown;
wpt->sat = -1;
wpt->session = curr_session();
+ wpt->gc_data = &empty_gc_data;
QUEUE_INIT(&wpt->Q);
return wpt;
if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) {
xfree((char *)(void *)wpt->icon_descr);
}
- if (wpt->gc_data.desc_short.utfstring) {
- xfree(wpt->gc_data.desc_short.utfstring);
- }
- if (wpt->gc_data.desc_long.utfstring) {
- xfree(wpt->gc_data.desc_long.utfstring);
- }
- if (wpt->gc_data.placer) {
- xfree(wpt->gc_data.placer);
+
+ if (wpt->gc_data != &empty_gc_data) {
+ geocache_data *gc_data = (geocache_data *)wpt->gc_data;
+
+ if (gc_data->desc_short.utfstring) {
+ xfree(gc_data->desc_short.utfstring);
+ }
+ if (gc_data->desc_long.utfstring) {
+ xfree(gc_data->desc_long.utfstring);
+ }
+ if (gc_data->placer) {
+ xfree(gc_data->placer);
+ }
+ if (gc_data->hint) {
+ xfree (gc_data->hint);
+ }
+ xfree(gc_data);
}
- if (wpt->gc_data.hint) {
- xfree (wpt->gc_data.hint);
- }
fs_chain_destroy( wpt->fs );
xfree(wpt);
}
else
return 0;
}
+
+geocache_data *
+waypt_alloc_gc_data(waypoint *wpt)
+{
+ geocache_data *res = (geocache_data *)wpt->gc_data;
+ if (res == &empty_gc_data) {
+ res = xcalloc(1, sizeof(*res));
+ wpt->gc_data = (const geocache_data *)res;
+
+ }
+ return res;
+}